<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="admin/head :: head" th:with="title=菜单列表">
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="layui-elem-field layuimini-search">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <a class="layui-btn" lay-submit lay-filter="data-search-btn">搜索</a>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="pause">暂停</a>
            <a class="layui-btn layui-btn-xs data-count-edit" lay-event="resume">恢复</a>
            <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="deletejob">删除</a>
        </script>
    </div>
</div>
<script type="text/javascript" th:inline="none">
    //layer   使用教程https://www.layui.com/doc/modules/laydate.html

    layui.use(['form','table','laydate','liuQi'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate,
            liuQi = layui.liuQi;
        var table_height=liuQi.getTableHeight($("fieldset").height());
        form.render();

        table.render({
            elem: '#currentTableId',
            url: '/admin/taskrepeat/queryList',
            cols: [[
                {field: 'jobName', title: '任务名称',align: "center"},
                {field: 'jobGroup', title: '任务组',align: "center"},
                {field: 'jobDescription', title: '描述',align: "center"},
                {field: 'jobStatusStr', title: '任务状态',align: "center"},
                {field: 'repeatCount', title: '重复次数',align: "center"},
                {field: 'runCount', title: '已执行次数',align: "center"},
                {field: 'interval', title: '间隔秒数',align: "center"},
                /*{field: 'roleId', title: '财富',align: "center",
                    templet: function (d) {
                        return d.id + "-" + d.name
                    }
                },*/
                {title: '操作', width: '10%', templet: '#currentTableBar', fixed: "right", align: "center"}
            ]],
            height:table_height,
            limits: [10, 20, 50, 100],
            limit: 20,
            page: true
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = data.field;

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: result
            }, 'data');
            return false;
        });


        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'pause') {
                liuQi.ajax('/admin/taskrepeat/pausejob',{"jobClassName":data.jobName,"jobGroupName":data.jobGroup});
            } else if (obj.event === 'resume') {
                liuQi.ajax('/admin/taskrepeat/resumejob',{"jobClassName":data.jobName,"jobGroupName":data.jobGroup});
            }else if (obj.event === 'deletejob') {
                liuQi.ajax('/admin/taskrepeat/deletejob',{"jobClassName":data.jobName,"jobGroupName":data.jobGroup});
            }
        });
    });

</script>
</body>
</html>